#include<stdio.h>
#include<conio.h>
#include<string.h>

struct sinhvien
{      
	   char ma[10];
	   char hd[10];
	   char ten[10];
       float diem1;
       float diem2;
       float diem3;
       float diem4;
       char hk[10];  
};


void nhap(sinhvien a[],int &n)
{   
	 printf(" nhap so sinh vien");scanf("%d",&n);
     for(int i=0;i<n;i++)
     {
             printf(" nhap thong tin sinh vien thu %d:",i+1);
             fflush(stdin);
             printf("\nnhap ma sv: ");							gets(a[i].ma);
             printf("\nnhap ho va ten dem sinh vien: "); 		gets(a[i].hd); 
             printf("\nnhap ten sinh vien: ");					gets(a[i].ten);
             printf("\nhap diem mon 1 2 3 4:");
             scanf("%f %f %f %f",&a[i].diem1,&a[i].diem2,&a[i].diem3,&a[i].diem4);
     		 fflush(stdin);
     		 printf("\n nhap hanh kiem sinh vien: ");	gets(a[i].hk);
	 }
 }
 
void in(sinhvien a[],int n)
{
      printf("	\n danh sach sinh vien ");
      printf(" | ma sv | ho va ten dem ten | diem mon 1-2-3-4   | hanh kiem | \n");
      for(int i=0; i<n; i++)
      printf(" |%s | %s | %s | %0.1f |  %0.1f |  %0.1f  |  %0.1f  |  %s  | \n ",a[i].ma,a[i].hd,a[i].ten,a[i].diem1,a[i].diem2,a[i].diem3,a[i].diem4,a[i].hk);
}

void tkm(sinhvien a[],int n)/* tim kiem theo msv*/
{
	char msv[10];
	printf("nhap msv cua sinh vien can tim kiem "); scanf("%s",&msv);
	for(int i=0;i<n;i++)
	if (strcmp(a[i].ma,msv)==0) 
	{
		printf(" |%s | %s | %s | %0.1f |  %0.1f |  %0.1f  |  %0.1f  |  %s  | \n ",&a[i].ma,&a[i].hd,&a[i].ten,&a[i].diem1,&a[i].diem2,&a[i].diem3,&a[i].diem4,&a[i].hk);
	}
}

void tkt(sinhvien a[],int n) /*tim kiem theo ten */
{
	char t[10];
	printf("nhap ten sinh vien can tim kiem "); scanf ("%s",&t);
	for(int i=0;i<n;i++)
	if (strcmp(a[i].ten,t)==0)
	{
	printf(" |%s | %s | %s | %0.1f |  %0.1f |  %0.1f  |  %0.1f  |  %s  | \n ",&a[i].ma,&a[i].hd,&a[i].ten,&a[i].diem1,&a[i].diem2,&a[i].diem3,&a[i].diem4,&a[i].hk);
	}
	
}



int main()
{	
	sinhvien a[10];
	int n;
	nhap(a,n);
	in(a,n);
	tkm(a,n);
	tkt(a,n);
	getch();
}
